<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jsontest</title>

    <script type="text/javascript">
        //编写一个js的对象
        var user = {
            name:"秦疆",
            age:3,
            sex:"男"
        };
    //将js对象转换成json字符串
    var str = JSON.stringify(user);
    console.log(str);

    //将json字符串转化成js对象
        var user2 = JSON.parse(str);
        console.log(user2);
    </script>
</head>
<body>

</body>
</html>